#!/usr/bin/env python

import MySQLdb
from tools import config

config.init ()

dbhost = config.getDBHost ()
dbuser = config.getDBUser ()
dbpass = config.getDBPass ()

db = MySQLdb.connect (host = dbhost, user = dbuser, passwd = dbpass, db = "pyhmon")
cur =  db.cursor ()

cur.execute ("""
    CREATE TABLE IF NOT EXISTS uptime
    (
	 id		INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
     node   CHAR(20),
     time   INT(10) UNSIGNED,
     value0 INT(8) UNSIGNED
    )
""")

cur.execute ("""
	CREATE TABLE IF NOT EXISTS loadavg
	(
	 id		INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
	 node	CHAR(20),
	 time	INT(10) UNSIGNED,
	 value0	FLOAT(4,2),
	 value1	FLOAT(4,2),
	 value2 FLOAT(4,2)
	)
""")

